package com.xiangge.demo;

public class TestDemo4 {
    /*定义猫类Cat。属性:毛的颜色color，品种breed。行为:吃饭eat()，抓老鼠catchMouse()
      定义狗类Dog。属性:毛的颜色color，品种breed。行为:吃饭()，看家lookHome()
要求:
	  1.按照以上要求定义Cat类和Dog类,属性要私有,生成空参、有参构造，set和get方法
	  2.定义测试类,在main方法中创建该类的对象并给属性赋值(set方法或有参构造方法)
	  3.调用成员方法,打印格式如下:
      花色的波斯猫正在吃鱼.....
      花色的波斯猫正在逮老鼠....
      黑色的藏獒正在啃骨头.....
      黑色的藏獒正在看家.....
*/
    public static class Cat{
        private String color;
        private String breed;

        public String getColor() {
            return color;
        }

        public void setColor(String color) {
            this.color = color;
        }

        public String getBreed() {
            return breed;
        }

        public void setBreed(String breed) {
            this.breed = breed;
        }
        public Cat(){}
        public Cat(String color,String breed){
            this.color = color;
            this.breed = breed;
        }
        public void eat(){
            System.out.println(color + "的" + breed + "正在吃鱼");
        }
        public void catchMouse(){
            System.out.println(color + "的"+ breed +"正在逮老鼠");
        }
    }
    public static class Dog{
        private String color;
        private String breed;

        public String getColor() {
            return color;
        }

        public void setColor(String color) {
            this.color = color;
        }

        public String getBreed() {
            return breed;
        }

        public void setBreed(String breed) {
            this.breed = breed;
        }
        public Dog(){}
        public Dog(String color,String breed){
            this.color = color;
            this.breed = breed;
        }
        public void eat(){
            System.out.println(color + "的"+ breed +"正在啃骨头");
        }
        public void lookhome(){
            System.out.println(color + "的"+ breed +"正在看家");
        }
    }

    public static void main(String[] args) {
        Cat c = new Cat("花色","波斯猫");
        c.eat();
        c.catchMouse();
        Dog d = new Dog("黑色","藏獒");
        d.eat();
        d.lookhome();
    }
}